package hspedu.learn.javabase;

public class Account {
    private String name;
    private double money;
    private String pwd;

    public Account() {
    }

    public Account(String name, double money, String pwd) {
        this.setPwd(pwd);
        this.setName(name);
        this.setMoney(money);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        if (name.length() == 4 || name.length() == 2 || name.length() == 3) {
            this.name = name;
        } else {
            System.out.println("名称长度不对，给了一个默认值");
            this.name = "周鑫龙";
        }
    }

    public double getMoney() {
        return money;
    }

    public void setMoney(double money) {
        if (money > 20) {
            this.money = money;
        } else {
            System.out.println("给你默认2远、0元钱");
            this.money = 20;
        }
    }

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        if (pwd.length() == 6) {
            this.pwd = pwd;
        } else {
            this.pwd = "123456";
        }
    }

    public void showInfo(Boolean bool) {
        if (bool) {
            System.out.println("name = " + name + " money=" + money + " pwd=" + pwd);
        } else{
            System.out.println("权限不够");
        }
    }
}
